<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="24">
          <el-form-item label="活动名称" prop="mobile">
            <el-input v-model="formData.mobile" placeholder="请输入活动名称" :maxlength="11" show-word-limit
                      clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="活动区域" prop="activityArea">
            <el-input v-model="formData.activityArea" placeholder="请输入活动区域" clearable
                      :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="日期选择" prop="date">
            <el-date-picker v-model="formData.date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                            :style="{width: '100%'}" placeholder="请选择日期" clearable></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="7">
          <el-form-item label="即时配送" prop="immediateDelivery" required>
            <el-switch v-model="formData.immediateDelivery"></el-switch>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="活动性质" prop="activityNature">
            <el-input v-model="formData.activityNature" clearable :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="特殊资源" prop="specialResource">
            <el-radio-group v-model="formData.specialResource" size="medium">
              <el-radio v-for="(item, index) in field103Options" :key="index" :label="item.value"
                        :disabled="item.disabled">{{item.label}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="活动形式" prop="activityForm">
            <el-input v-model="formData.activityForm" type="textarea" :autosize="{minRows: 4, maxRows: 4}"
                      :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label-width="82px" label="" prop="immediateDelivery">
            <el-button type="primary" icon="el-icon-search" size="medium"> 主要按钮 </el-button>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>

<script>
export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        mobile: '',
        activityArea: undefined,
        date: null,
        immediateDelivery: false,
        activityNature: undefined,
        specialResource: 1,
        activityForm: undefined,
      },
      rules: {
        mobile: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { pattern: /^1(3|4|5|7|8|9)\d{9}$/, message: '手机号格式错误', trigger: 'blur' }
        ],
        activityArea: [
          { required: true, message: '请输入活动区域', trigger: 'blur' }
        ],
        date: [
          { required: true, message: '请选择日期', trigger: 'change' }
        ],
        immediateDelivery: [
          { required: true, message: '即时配送不能为空', trigger: 'change' }
        ],
        activityNature: [
          { required: true, message: '请输入活动性质', trigger: 'blur' }
        ],
        specialResource: [
          { required: true, message: '特殊资源不能为空', trigger: 'change' }
        ],
        activityForm: [
          { required: true, message: '请输入活动形式', trigger: 'blur' }
        ]
      },
      field103Options: [
        { label: '线上商品商赞助', value: 1 },
        { label: '线下商品商赞助', value: 2 }
      ],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}
</script>

<style>
</style>
